﻿using System;
using System.Runtime.Serialization;

namespace SBPweb.PROvibe.Shared.Actors
{

    [DataContract]
    public struct TypeDescriptor
    {

        public TypeDescriptor(string fullName)
        {
            Uri uri = new Uri(fullName);
            XapPath = uri.Host;
            AssemblyPath = uri.LocalPath.Substring(1);
            FullyQualifiedTypeName = uri.Query.Substring(uri.Query.IndexOf("class=") + 6);
        }

        public TypeDescriptor(string xapPath, string asmPath, string typeName)
        {
            XapPath = xapPath;
            AssemblyPath = asmPath;
            FullyQualifiedTypeName = typeName;
        }

        [DataMember]
        public string XapPath;

        [DataMember]
        public string AssemblyPath;

        [DataMember]
        public string FullyQualifiedTypeName;

        public override string ToString()
        {
            return string.Format("xap://{0}/{1}?class={2}", XapPath, AssemblyPath, FullyQualifiedTypeName);
        }

    }

}
